home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1183 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.1 KB

  1. From: vandevod@cs.rpi.edu (David Vandevoorde)
  2. Message-ID: <xso20li5q6z.fsf@avs.cs.rpi.edu>
  3. X-Original-Date: 20 Apr 1996 21:19:33 -0400
  4. Path: in2.uu.net!bounce-back
  5. Date: 21 Apr 96 07:02:43 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Member templates
  9. Organization: RPI Computer Science
  10. References: <31763F3F.805@cs.tu-berlin.de> <xsoivewlve3.fsf@avs.cs.rpi.edu>
  11.     <3178D6BB.7167@cs.tu-berlin.de>
  12. In-Reply-To: Roman Lechtchinsky's message of 20 Apr 96 16:16:11 GMT
  13. X-Newsreader: Gnus v5.1
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBFAgUBMXndnOEDnX0m9pzZAQFY2AF/TgdEtb8Is8KxxmYBK6i85dwDsPSFyX9u
  16.     jQrFzdMv61NSRmSCEdd9ic1lO2eftxrx
  17.     =s8X0
  18.  
  19. >>>>> "RL" == Roman Lechtchinsky <wolfro@cs.tu-berlin.de> writes:
  20. RL> David Vandevoorde wrote:
  21. >> 
  22. >> >>>>> "RL" == Roman Lechtchinsky <wolfro@cs.tu-berlin.de> writes:
  23. >> [...]
  24. RL> class Base
  25. RL> {
  26. RL> virtual void f(int);
  27. RL> };
  28. >> 
  29. RL> class Derived : Base
  30. RL> {
  31. RL> template<class T> void f(T);
  32. RL> };
  33. >> 
  34. RL> Is this legal? If so, will the template function f(int) override
  35. RL> Base::f(int)? If so, when will it be instantiated? And, last but not
  36. RL> least, which section of the DWP handles this case? Thanks in advance.
  37. >> 
  38. >> I believe this is legal and the instantiated member function is not
  39. >> virtual (i.e., no overriding), but my reason extrapolates the WPs
  40. >> somewhat. I base this on the fact that the `signature' of a template
  41. >> function includes the actual template arguments ([temp.over.link]
  42. >> 14.10.4/3 in the April CD), and that when [class.virtual] 10.3/2
  43. >> requires `same name', `name' really means template-id and not just
  44. >> template-name ([temp.names] 14.1).
  45. >> 
  46.  
  47. RL> IMO, this means that f cannot be overridden in Derived:
  48.  
  49. RL> class Derived : Base
  50. RL> {
  51. RL>  template<class T> void f(T);
  52. RL>  void f(int);
  53. RL> };
  54.  
  55. RL> would be a specialization which means that f doesn't override as it is
  56.                ^^^^^^^^^^^^^^
  57. To me more precise: it would be a ``guiding member-function declaration'',
  58. if such a beast is supposed to exist (i.e., it declares a specialization,
  59. but only to guide overloading resolution --- the definition is still
  60. generated from the template). However...
  61.  
  62. RL> still a template ( [temp.over.spec] 14.10.5 ). Is this interpretation
  63. RL> correct?
  64.  
  65. Frankly, I don't know. I can see three reasonable possibilities:
  66.  
  67. 1) your interpretation,
  68. 2) it is not a guiding declaration but an overriding function.
  69.    A guiding declaration could instead perhaps be declared via:
  70.  
  71.     struct Derived: Base {
  72.         template<typename T>
  73.         void f(T);
  74.         void f<int>(int); // Guiding member function declaration
  75.         void f(int);      // Virtual function overriding Base::f(int);
  76.     };
  77.  
  78. 3) it is simply illegal C++ code.
  79.  
  80. I suspect 1) is true, but I'm really not sure at all...
  81.  
  82.     Daveed
  83. ---
  84. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  85. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  86. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  87. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  88. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  89.